import type { PlusColumn } from 'plus-pro-components'

import { getMessageGroups } from '@fl/api/ums-api'

export function useForm() {
    const schema: PlusColumn[] = [

        {
            colProps: {
                span: 6,
            },
            label: '通知主题',
            options: [
                {
                    label: '好房',
                    value: 'HAOFANG',
                },
                {
                    label: '保障房',
                    value: 'BAOZHANGFANG',
                },
                {
                    label: '政策',
                    value: 'ZHENGCE',
                },
                {
                    label: '登录',
                    value: 'DENGLU',
                },
            ],
            prop: 'scene',
            valueType: 'select',
        },
        {
            colProps: {
                span: 6,
            },
            label: '通知分类',
            options: async () => {
                const data = await getMessageGroups()
                return data.map((item: { group_name: string, id: number | string }) => {
                    return {
                        label: item.group_name,
                        value: item.id,
                    }
                })
            },
            prop: 'group_id',
            valueType: 'select',
        },
    ] as const

    const form = ref({
        channel: 'WeChatApp',
        group_id: '',
        order: 'desc',
        scene: '',
        sort_by: 'create_time',
    })
    return { form, schema }
}
